home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 8 / Power CD-ROM 8.iso / prgmming / oldutil / fecho.asm < prev    next >
Encoding:
Assembly Source File  |  1994-12-10  |  2.1 KB  |  92 lines

  1.     Name fecho
  2.     Title
  3.     page    ,132
  4. comment /
  5.  
  6.     This program is a filter that reads from standard input and
  7.     echoes both to standard out and standard error output.  This
  8.     is useful when debugging filter sequences because it allows
  9.     you to view the intermediate data as the commands are executed.
  10.  
  11. /
  12. ;===================================================================
  13. code    segment    public
  14. ;===================================================================
  15. ;
  16. ;    command line is at 80h of psp - first byte is length
  17. ;
  18.     org    80h
  19. parmsize    db    ?
  20. parm        db    7fh dup (?)
  21. ;
  22. ; .com starts at 100h - but must jump around any data area
  23. ;
  24.     org    100h            ; com file starts here
  25.     assume    cs:code,ds:code,es:code
  26. fecho:
  27.     jmp    clear
  28. ;===================================================================
  29. ;
  30. ; data area for .com programs
  31. ;
  32. inchar      db    ?
  33. ;
  34. ;===================================================================
  35. clear:
  36. ;
  37. ; start of actual code is here (clear)
  38. ;
  39.     mov    ah,30h        ; get dos version
  40.     int    21h
  41.     cmp    al,2        ; must be at least 2.0
  42.     jb    oops
  43. ;
  44. ; release uneeded memory
  45. ;
  46.     mov    bx,offset bos[256]    ; 256 byte local stack
  47.     mov    sp,bx
  48.     mov    cx,4
  49.     sar    bx,cl
  50.     inc    bx        ; paragraphs needed = end/16 + 1
  51.     mov    ah,4ah        ; SETBLOCK
  52.     int    21h
  53. ;
  54. ; These two i/o parameters are constants.
  55. ;
  56.     mov    dx,offset inchar
  57.     mov    cx,1h        ; get 1 character
  58. again:
  59. ;
  60. ; read a character
  61. ;
  62.     xor    bx,bx        ; zero is handle of standard input
  63.     mov    ah,3fh        ; read a file/device function
  64.     int    21h        ; invoke the function
  65. ;
  66. ; if carry set of ax=0 exit
  67. ;
  68.     jc    oops        ; i/o error
  69.     or    ax,ax        ; set flags
  70.     jz    oops        ; eof
  71. ;
  72. ; now output to standard output
  73. ;
  74. output:
  75.     mov    bx,1h        ; standard output handle
  76.     mov    ah,40h        ; dx still points at inchar
  77.     int    21h        ; call dos output function
  78. ;
  79. ; now output to error output as an echo
  80. ;
  81.     mov    bx,2h        ; standard output handle
  82.     mov    ah,40h        ; dx still points at inchar
  83.     int    21h        ; call dos output function
  84.     jmp    again        ; repeat cycle
  85. oops:
  86.     int    20h        ; return to dos
  87.  
  88. bos    label    near        ; bottom of stack
  89.  
  90. code    ends
  91.     end    fecho
  92.